package com.anyou.mall.goo.goods.dto;

import com.anyou.mall.goo.goods.domain.LiGoodsSku;
import com.anyou.mall.goo.goodsSku.domain.GooGoodsSku;
import com.anyou.mall.goo.specs.domain.SpeSpecs;
import com.baomidou.mybatisplus.annotation.EnumValue;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 商品操作DTO
 *
 * @author pikachu
 * @since 2020-02-24 19:27:20
 */
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class GoodsOperationDTO implements Serializable {

    private static final long serialVersionUID = -509667581371776913L;

    @ApiModelProperty(value = "商家ID （如果平台创建商品传0）")
    private Long storeId;

    @ApiModelProperty(value = "商品id 修改传")
    private Long goodsId;

    @ApiModelProperty(value = "商品价格（销售价格）", required = true)
    @Min(value = 0, message = "商品价格不能为负数")
    @Max(value = 99999999, message = "商品价格不能超过99999999")
    private Double price;

    @ApiModelProperty(value = "商品原价格（商品列表两个价格 这个价格是灰色被划掉的那个）", required = true)
    @Min(value = 0, message = "商品原价格不能为负数")
    @Max(value = 99999999, message = "商品价格不能超过99999999")
    private Double rawPrice;

    /*@ApiModelProperty(value = "商品运费", required = true)
    @NotNull(message = "商品运费不能为空")
    @Min(value = 0, message = "商品运费不能为负数")
    @Max(value = 99999999, message = "商品运费不能超过99999999")
    private Double freight;*/

    @ApiModelProperty(value = "最低购买数")
    private Integer minBuyNumber;

    @ApiModelProperty(value = "分类path (水票商品默认传一级水票分类)", required = true)
    @Size(max = 300, message = "选择了太多分类")
    private String categoryPath;

    @ApiModelProperty(value = "商品类型（0普通商品，1水票商品）")
    private Integer goodType;

    /*@ApiModelProperty(value = "店铺分类id", required = true)
    @Size(max = 200, message = "选择了太多店铺分类")
    private String storeCategoryPath;*/

    /*@ApiModelProperty(value = "品牌id")
    @Min(value = 0, message = "品牌值不正确")
    private String brandId;*/

    @ApiModelProperty(value = "商品名称", required = true)
    @NotEmpty(message = "商品名称不能为空")
    @Length(max = 50, message = "商品名称不能超过50个字符")
    private String goodsName;

    /*@ApiModelProperty(value = "商品pc端详情")
    private String intro;*/

    @ApiModelProperty(value = "商品移动端详情")
    private String mobileIntro;

    @ApiModelProperty(value = "库存预警")
    @Min(value = 0, message = "库存预警不能为负数")
    @Max(value = 99999999, message = "库存预警不能超过99999999")
    private Integer stockWarning;

    /*@ApiModelProperty(value = "是否立即发布")
    private Boolean release;*/

    @ApiModelProperty(value = "是否为推荐商品（0否 1是）")
    private String appIndexStatus;

    @ApiModelProperty(value = "商品参数 （spu）")
    private List<GoodsParamsDTO> goodsParamsDTOList;

    @ApiModelProperty(value = "商品图片 （逗号拼接返回的也是逗号拼接）")
    @NotBlank(message = "商品图片不能为空")
    private String goodsGalleryList;

    /*@ApiModelProperty(value = "运费模板id,不需要运费模板时值是0", required = true)
    @NotNull(message = "运费模板不能为空，没有运费模板时，传值0")
    @Min(value = 0, message = "运费模板值不正确")
    private String templateId;*/

    /*@ApiModelProperty(value = "卖点")
    private String sellingPoint;*/

    /**
     * 销售模式
     */
    /*@ApiModelProperty(value = "销售模式", required = true)
    private String salesModel;*/

    @ApiModelProperty(value = "是否重新生成sku数据")
    private Boolean regeneratorSkuFlag = true;

    /**
     * 商品类型
     */
    /*@ApiModelProperty(value = "商品类型 （0实物商品 1虚拟商品）")
    private String goodsType;*/

    /**
     * 商品视频
     */
    @ApiModelProperty(value = "商品视频")
    private String goodsVideo;

    @ApiModelProperty(value = "赠送积分值")
    @Max(value = 99999999, message = "赠送积分值不能超过99999999")
    private Integer giveIntegralNum;

    @ApiModelProperty(value = "是否可用水票（0可以使用，1不能使用）")
    private Integer ifWaterTicket;


    /**
     * 别看这个这个不在前端显示
     */
    @ApiModelProperty(value = "sku列表", hidden = true )
    @Valid
    private List<Map<String, Object>> goodsSkus;

    @ApiModelProperty("商品sku List")
    private List<LiGoodsSku> skuList;

    @ApiModelProperty("商品规格List")
    private List<SpeSpecs> specsList;

    /*@ApiModelProperty(value = "是否为商品模版")
    private Boolean goodsTemplateFlag = false;*/
    /**
     * 批发商品规则
     */
    /*@ApiModelProperty(value = "批发商品规则")
    private List<WholesaleDTO> wholesaleList;*/

    /*@ApiModelProperty(value = "注意事项")
    private String needingAttention;*/


    /*@ApiModelProperty(value = "是否为年度会员专属")
    private Boolean annualFeeExclusive;*/

    /*@ApiModelProperty(value = "浏览权限")
    private String browsePermissions;*/

    public String getGoodsName() {
        //对商品对名称做一个极限处理。这里没有用xss过滤是因为xss过滤为全局过滤，影响很大。
        // 业务中，全局代码中只有商品名称不能拥有英文逗号，是由于商品名称存在一个数据库联合查询，结果要根据逗号分组
        return goodsName.replace(",", "");
    }

    @ApiModelProperty("是否为积分商品（0-否，1-是）")
    private Integer isJf;

    @ApiModelProperty("积分商品库存")
    private Integer jfStock;

    @ApiModelProperty("积分值")
    private Integer jfValue;

    @ApiModelProperty("积分商品类型（0-实体商品，1-虚拟商品）")
    private String jfType;


}
